package com.example.news.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.news.R;
import com.example.news.adapter.OneAdapter;
import com.example.news.bean.OneBean;
import com.example.news.iteam.Iteam_oneActivity;

import java.util.ArrayList;

public class YuleiFragment extends Fragment {
    private ListView one_listView;
    private ArrayList<OneBean> list;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_changshang, container, false);
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        list=new ArrayList<>();
        init();
        one_listView=getActivity().findViewById(R.id.changshang_listView);
        one_listView.setAdapter(new OneAdapter(list,getActivity()));
        one_listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent=new Intent(getActivity(), Iteam_oneActivity.class);
                intent.putExtra("i",list.get(i).getIndex()+"");
                intent.putExtra("name",list.get(i).getName());
                startActivity(intent);
                //Toast.makeText(getActivity(), ""+list.get(i).getIndex(),Toast.LENGTH_SHORT).show();
            }
        });
    }
    private void init() {
        list.add(new OneBean(R.drawable.sj1,R.drawable.sj2,R.drawable.sj3,61,"李双江儿子李天一近况曝光，狱中组乐队黑瘦认不出，刑期仅剩3年"));
        list.add(new OneBean(R.drawable.sj4,R.drawable.sj5,R.drawable.sj6,62,"浙江卫视，这次玩砸了吧"));
        list.add(new OneBean(R.drawable.sj7,R.drawable.sj8,R.drawable.sj9,63,"跨年晚会成“卸妆晚会”，离开美颜滤镜，女星们的颜值很真实"));
        list.add(new OneBean(R.drawable.sj10,R.drawable.sj11,R.drawable.sj12,64,"贾乃亮在离婚后在上热搜，网友：这样的男人，用不着同情"));
        list.add(new OneBean(R.drawable.sj13,R.drawable.sj14,R.drawable.sj15,65,"跨年晚会：汪涵频繁黑脸，何炅全程脱稿，主持地位巧妙展现"));
        list.add(new OneBean(R.drawable.sj16,R.drawable.sj17,R.drawable.sj18,66,"曾与成龙搭档《宝贝计划》的宝宝，如今14岁，长相变得认不出"));



    }
}
